/*
 * @(#)Constants.java Apr 27, 2007
 * 
 * Copyright 2007 by ChinanetCenter Corporation.
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * ChinanetCenter Corporation ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with ChinanetCenter.
 * 
 */
package com.cnc.fd;

import com.cnc.fd.util.FdProperties;

/**
 * @author 阿闲
 * @date   Apr 27, 2007
 * @version 1.0
 */

public class Constants {
	
	public static final String TASK_TYPE_MANUAL = "manual";
	public static final String TASK_TYPE_AUTO = "auto";	
	public static final String TASK_TYPE_MONITOR = "monitor";
	public static final String TASK_TYPE_SYNCSERVER = "syncServer";
	
	public static final int HTTP_THREADS_SAMEISP=FdProperties.getIntProperty("HTTPDOWNLOAD_THREADS_SAMEISP"); //相同运营商之间互传是http下载线程数
	public static final int HTTP_THREADS_DIFFISP=FdProperties.getIntProperty("HTTPDOWNLOAD_THREADS_DIFFISP");//不同...
	/**
	 * 引擎状态
	 */
	public static final String TASK_ENGINE_RUN = "run";
	public static final String TASK_ENGINE_STOP = "stop";
	

	/**
	 * 下载服务器、运营商、机房的文件同步状态
	 */
	public static final String SYNC_STATUS_UN_SYNC = "unSync";//未同步
	public static final String SYNC_STATUS_CUR_SYNC = "curSync";//正在同步
	public static final String SYNC_STATUS_HAS_SYNC = "hasSync";//已同步
	public static final String SYNC_STATUS_FAL_SYNC = "falSync";//同步失败
	
	/**
	 * 任务状态
	 */
	public static final String TASK_STATUS_WAIT = "wait";//等待同步
	public static final String TASK_STATUS_RUN = "run";//正在同步
	public static final String TASK_STATUS_STOP = "stop";//任务中止
	public static final String TASK_STATUS_SUCCESS = "success";//同步成功
	public static final String TASK_STATUS_FAILURE = "failure";//同步失败
	public static final String TASK_STATUS_SUSPEND = "suspend";//
	public static final String TASK_STATUS_CANCEL = "cancel";
	public static final String TASK_STATUS_OPERATOR = "operator"; // 运维处理中
	
	public static final String TASK_STATUS_TOCANCEL =  "toCancel";
	public static final String TASK_STATUS_CURCANCEL = "curCancel";
	public static final String TASK_STATUS_HASCANCEL = "hasCancel";
	public static final String TASK_STATUS_FALCANCEL = "falCancel";
	
	public  static final String TASK_RATE_OF_PROGRESS_COMPLETE = "100%";
	
	/**
	 * 任务类型
	 */

	public static final String TASK_KIND_UPLOAD = "upload";	
	public static final String TASK_KIND_MKDIR = "mkdir";
	public static final String TASK_KIND_DELETE = "delete";
	public static final String TASK_KIND_RENAME = "rename";	
	public static final String TASK_KIND_SYNCCUSTOMNER = "syncCustomer";
	public static final String TASK_KIND_CHECKFILE = "checkfile";
	public static final String TASK_KIND_SYNCMACHINE = "syncMachine";
	public static final String TASK_KIND_UPDATECUSTOMER = "updateCustomer";
	public static final String TASK_KIND_UPDATEMACHINE = "updateMachine";
	public static final String TASK_KIND_CHECKCUSTOMER = "checkCustomer";
	public static final String TASK_KIND_COPY= "copy";
	public static final String TASK_KIND_DECOMPRESS = "decompress";
	public static final String TASK_KIND_MD5SUM = "md5sum";
	public static final String TASK_KIND_SYNCSERVER = "syncServer";
	public static final String TASK_KIND_CANCEL_SYNC_SERVER = "cancelSyncServer";
	public static final String TASK_KIND_MD5FAILURE = "md5failure";
	
	public static final String TASK_KIND_RSYN = "rsyn";
	
	//tcs socket port
	public static final int TCS_SOCKET_PORT = FdProperties.getIntProperty("TCS_SOCKET_PORT");
	
	/**
	 * 传输协议
	 */
	public static final String PROTOCOL_SCP = "scp";
	public static final String PROTOCOL_WS = "wsftp";
	public static final String PROTOCOL_HTTP = "http";
	
	//压缩方式
	public static final String COMPRESS_ZIP = "zip";
	
	/**
	 * 调度的系统常量
	 */
	//文件同步的总超时时间
	public static final int DEFAULT_UPLOAD_SYNC_TIMEOUT_MINUTES = FdProperties.getIntProperty("DEFAULT_UPLOAD_SYNC_TIMEOUT_MINUTES");
	
	//默认最大失败次数
	public static final int DEFAULT_MAX_FAILURE_TIMES = FdProperties.getIntProperty("DEFAULT_MAX_FAILURE_TIMES");
	
	//默认同步取消超时等待时间(分钟)
	public static final int DEFAULT_CANCELUPLOAD_TIMEOUT_MINUTES = FdProperties.getIntProperty("DEFAULT_CANCELUPLOAD_TIMEOUT_MINUTES");
	
	//默认其它任务超时时间
	public static final int DEFAULT_OTHER_TASK_TIMEOUT_MINUTES = FdProperties.getIntProperty("DEFAULT_OTHER_TASK_TIMEOUT_MINUTES");
	
	//默认COPY任务超时时间
	public static final int DEFAULT_COPY_TASK_TIMEOUT_MINUTES = FdProperties.getIntProperty("DEFAULT_COPY_TASK_TIMEOUT_MINUTES");
	
	//任务引擎休眠时间
	public static final int DEFAULT_TASKENGINE_SLEEP_SECONDS = FdProperties.getIntProperty("DEFAULT_TASKENGINE_SLEEP_SECONDS");	
	
	//上传调度休眠时间
	public static final int DEFAULT_UPLOAD_TASK_SCHEDULE_SLEEP_SECONDS = FdProperties.getIntProperty("DEFAULT_UPLOAD_TASK_SCHEDULE_SLEEP_SECONDS");
	
	//其它调度休眠时间
	public static final int DEFAULT_OTHER_TASK_SCHEDULE_SLEEP_SECONDS = FdProperties.getIntProperty("DEFAULT_OTHER_TASK_SCHEDULE_SLEEP_SECONDS");
	
	//socket连接超时时间
	public static final int DEFAULT_SOCKET_CONNECT_TIMEOUT_SECONDS = FdProperties.getIntProperty("DEFAULT_SOCKET_CONNECT_TIMEOUT_SECONDS");
	
	//socket回复等待时间 
	public static final int DEFAULT_SOCKET_REPLAY_TIMEOUT_SECONNS = FdProperties.getIntProperty("DEFAULT_SOCKET_REPLAY_TIMEOUT_SECONNS");
	
	//控制系统的并发同步文件数
	public static final int DEFAULT_MAX_UPLOAD_TASK = FdProperties.getIntProperty("DEFAULT_MAX_UPLOAD_TASK");
	
	public static final int DEFAULT_MAX_OTHER_TASK = FdProperties.getIntProperty("DEFAULT_MAX_OTHER_TASK");;
	
	//同步机房的速度（k）
	public static final int OVER_NODE_SPEED = FdProperties.getIntProperty("OVER_NODE_SPEED");
	//同机房的同步速度
	public static final int SAME_NODE_SPEED = FdProperties.getIntProperty("SAME_NODE_SPEED");
	//通讯时间(秒)
	public static final int COMMUNICATE_TIME = FdProperties.getIntProperty("COMMUNICATE_TIME");
	//同步机房内机器超时时间
	public static final int SAME_NODE_TIMEOUT_MINUTES = FdProperties.getIntProperty("SAME_NODE_TIMEOUT_MINUTES");
	//跨运营超时时间
	public static final int OVER_CARRYCOMPANY_SPEED = FdProperties.getIntProperty("OVER_CARRYCOMPANY_SPEED");
	
	//ws协议的选择（1－跨运营商，2－跨运营商和跨机房，3－全部用ws）
	public static final String DEFAULT_PROTOCOL_CHOICE = FdProperties.getProperty("DEFAULT_PROTOCOL_CHOICE");
	
	//运营商已同步，是否再允许进行跨运营商同步（yes－允许，no－不允许）
	public static final String IS_ALLOW_OVER_CARRYCOMPANY = FdProperties.getProperty("IS_ALLOW_OVER_CARRYCOMPANY");
	
	//跨运营商同步方式的选择，（0－仅空闲的机器可以做跨运营同步且仅同步一台目标机器；1－只要目标机器数未达到最大值，即可做跨运营商同步）
	public static final String OVER_CARRYCOMPANY_CHOICE = FdProperties.getProperty("OVER_CARRYCOMPANY_CHOICE");
	
	
	//同时允许传输的目标机器数
	public static final int MAX_SYNC_TARGET_NO = FdProperties.getIntProperty("MAX_SYNC_TARGET_NO");
	
	public static final int MAX_WSFTP_UPLOAD = FdProperties.getIntProperty("MAX_WSFTP_UPLOAD");
	public static final int MAX_WSFTP_RECEIVE = FdProperties.getIntProperty("MAX_WSFTP_RECEIVE");
	public static final int MAX_SCP_UPLOAD = FdProperties.getIntProperty("MAX_SCP_UPLOAD");
	public static final int MAX_SCP_RECEIVE = FdProperties.getIntProperty("MAX_SCP_RECEIVE");
	public static final int MAX_HTTP_RECEIVE= FdProperties.getIntProperty("MAX_HTTP_RECEIVE");
	public static final int MAX_HTTP_UPLOAD = FdProperties.getIntProperty("MAX_HTTP_UPLOAD");
	
	// 同一个源同步失败后重试的次数
	public static final int MAX_SAME_SERVER_SYNC_COUNT = FdProperties.getIntProperty("MAX_SAME_SERVER_SYNC_COUNT");
	/**
	 * 服务器状态
	 */
	public static final String SERVER_ACTIVE_TRUE = "0";//服务器可用
	public static final String SERVER_ACTIVE_FALSE = "1";//服务器不可用
	
	/**
	 * 邮件常量
	 */
	public static final String IS_MAIL_SENDER_TO_CUSTOMER = FdProperties.getProperty("IS_MAIL_SENDER_TO_CUSTOMER");//是否发送邮件	
	public static final String OPERATOR_MAIL_ADDRESS = FdProperties.getProperty("OPERATOR_MAIL_ADDRESS");
	public static final String SENDER_FROM = FdProperties.getProperty("SENDER_FROM");
	
	//同步失败，是否允许移动
	public static final String IS_MOVE_IF_FAILURE = FdProperties.getProperty("IS_MOVE_IF_FAILURE");
	
	//upload时是否需要临时目录，然后在rename（yes or no）	
	public static final String IS_NEED_TEMP_DIR = "no";
	
	//是否需要向其他系统报告同步完成情况（yes or no）
	//public static final String IS_NEED_REPORT = FdProperties.getProperty("IS_NEED_REPORT");
	
	//同步情况汇报地址url
	public static final String SYNC_REPORT_URL = FdProperties.getProperty("SYNC_REPORT_URL");
	
	public static final String REPORT_SYNC_SUCCESS = "sync_finish";
	public static final String REPORT_SYNC_FAILURE = "sync_failed";
	public static final String REPORT_SYNC_RUNNING = "sync_running";
	public static final String REPORT_DELETE_SUCCESS = "delete_finish";
	public static final String REPORT_DELETE_FAILURE = "delete_failed";
	public static final String REPORT_RENAME_SUCCESS = "rename_finish";
	public static final String REPORT_RENAME_FAILURE = "rename_failed";
	public static final String REPORT_UNZIP_SUCCESS = "unzip_finish";
	public static final String REPORT_UNZIP_FAILURE = "unzip_failed";
	
	public static final String IS_REPORT_S = "S";//已汇报成功
	public static final String IS_REPORT_N = "N";//未汇报
	public static final String IS_REPORT_F = "F";//已汇报失败
	
	//public static final int REPORT_ALLOW_FAL_COUNT = FdProperties.getIntProperty("REPORT_ALLOW_FAL_COUNT");
	
	public static final String RESPONSE_SUCCESS = "0";
	public static final String RESPONSE_FAILURE = "-1";
	
	
	public static final int SYNC_CARRYCOMPANY = 0;//同步运营商
	public static final int SYNC_CARRYCOMPANY_NODE = 1;//同步机房
	public static final int SYNC_NODE_SERVER = 2;//同步机房内的机器
	
	public static final String IS_SOURCE_SYNC_ONCE = FdProperties.getProperty("IS_SOURCE_SYNC_ONCE");	
	
	public static final String IS_NEED_MD5SUM = FdProperties.getProperty("IS_NEED_MD5SUM");	
	
	
	public static final long NO_TIME_OUT = 0;
	
	//消息发送队列中，等待发送的超时分钟
	public static final int MSG_SEND_QUEUE_TIME_OUT_MINS = 9;
	
	//public static final String IS_SYNC_NEW_TASK_FIRST = FdProperties.getProperty("IS_SYNC_NEW_TASK_FIRST");
	
	public static final int DEFAULT_CUSTOMER_PRIORITY = 50;
	
	public static final int DEFAULT_CUSTOMER_UPLOAD_TASK_COUNT = FdProperties.getIntProperty("DEFAULT_CUSTOMER_UPLOAD_TASK_COUNT");
	
	public static final int DEFAULT_CUSTOMER_OTHER_TASK_COUNT = FdProperties.getIntProperty("DEFAULT_CUSTOMER_OTHER_TASK_COUNT");
	public static final int DEFAULT_DAY_UPLOAD_SYNC_COUNT = FdProperties.getIntProperty("DEFAULT_DAY_UPLOAD_SYNC_COUNT");
	
	public static final int MESSAGE_SENDER_POOL_SIZE = FdProperties.getIntProperty("MESSAGE_SENDER_POOL_SIZE");
	
	/**
	 * 汇报类型* 
	 */
	public static final String REPORT_TYPE_NO = "0";//不汇报
	public static final String REPORT_TYPE_TUDOU = "1";//土豆第一次汇报接口
	public static final String REPORT_TYPE_PERLTV = "2";//南方明珠汇报接口
	public static final String REPORT_TYPE_TUDOU2 = "3";//土豆第二次汇报接口	
	
	public static final String BOOL_YES = "Y";
	public static final String BOOL_NO = "N";
	
	
	//错误类型
	public static final String ERRNO_OVERTIME = "99";
	
	public static final String ERRNO_RESPONSE_TIMEOUT = "99";
	
	//SOCKET相关错误码100~199
	public static final String ERRNO_SOCKET_CONNECT_FAILURE = "100";
	public static final String ERRNO_SOCKET_CONNECT_TIMEOUT = "101";
	public static final String ERRNO_SOCKET_READ_TIMEOUT = "102";
	
	//操作相关的错误码200~299
	public static final String ERRNO_DELETE_FAILURE = "200";
	public static final String ERRNO_RENAME_FAILURE = "201";
	public static final String ERRNO_MD5SUM_FAILURE = "202";
	public static final String ERRNO_COPY_FAILURE = "203";
	public static final String ERRNO_MKDIR_FAILURE = "204";
	public static final String ERRNO_DECOMPRESS_FAILURE = "205";
	
	public static final String UNSOURCE_NODES=FdProperties.getProperty("UNSOURCE_NODES");
	
	public static final String IS_FAILURE_ALARM=FdProperties.getProperty("IS_FAILURE_ALARM");
	
	public static final int MONITOR_INGORE_MINUTES = FdProperties.getIntProperty("MONITOR_INGORE_MINUTES");
	public static final int FILE_CHECE_RUN_TASK_COUNT = FdProperties.getIntProperty("FILE_CHECE_RUN_TASK_COUNT");
	public static final int FILE_CHECK_OVER_TIME = FdProperties.getIntProperty("FILE_CHECK_OVER_TIME");
	
	// 消息来源类型
	public static final String SOURCE_TYPE_FTP = "1";      // 通过ftp上传
	public static final String SOURCE_TYPE_RELEASE = "2";  // 通过release上传
	
	// 反馈重试的次数
	public static final int FEEDBACK_MAX_SEND_TIME = FdProperties.getIntProperty("FEEDBACK_MAX_SEND_TIME");
	
	// 反馈线程执行的时间间隔
    public static final int FEEDBACK_EXEC_INTERVAL = FdProperties.getIntProperty("FEEDBACK_EXEC_INTERVAL");
	
	public static void main(String[] args){
		System.out.println(DEFAULT_TASKENGINE_SLEEP_SECONDS);
	}


	
}


